# Contributor: Chloe Kudryavtsev <toast@toast.cafe>
# Maintainer: Chloe Kudryavtsev <toast@toast.cafe>
pkgname=watchexec
pkgver=1.20.4
pkgrel=0
pkgdesc='Executes commands in response to file modifications'
url='https://github.com/watchexec/watchexec'
arch='x86_64 x86 armhf armv7 aarch64 ppc64le' # limited by rust/cargo
license='Apache-2.0'
makedepends='cargo'
checkdepends="bash"
subpackages="$pkgname-doc
	$pkgname-zsh-completion
	"
source="https://github.com/watchexec/watchexec/archive/refs/tags/cli-v$pkgver.tar.gz"
builddir="$srcdir/watchexec-cli-v$pkgver"

case "$CARCH" in
arm*|aarch64|ppc64le)
	# weirdly failing tests
	options="$options !check"
	;;
esac

export CARGO_HOME="$srcdir"/cargo

prepare() {
	default_prepare
	cargo fetch --locked
}

build() {
	cargo build \
		--release \
		--verbose \
		--frozen
}

check() {
	cargo test --all \
		--release \
		--verbose \
		--frozen
}

package() {
	install -Dm755 target/release/"$pkgname" "$pkgdir"/usr/bin/"$pkgname"
	install -Dm644 doc/"$pkgname".1 "$pkgdir"/usr/share/man/man1/"$pkgname".1
	install -Dm644 "$builddir"/completions/zsh \
		"$pkgdir"/usr/share/zsh/site-functions/_watchexec
}

sha512sums="
24559edc231859186c6a41f4105bf9e597b74925a594a4d1e6928beac43fd8c755d4540f1f78d9837e9234f556bf6dd04636420fbc3365d72fe9f81cf967cbd4  cli-v1.20.4.tar.gz
"
